package sea.plot;

import java.util.ArrayList;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import sea.util.PublicParam;
import sea.util.WinHelper;

/**
 *
 * This class builds the layout of main interface of Plot
 * 
 * @author  Zhirun Ding
 * 
 * Created on 05/07/2012
 * 
 */

public class PlotForm extends javax.swing.JDialog {
    
    /** Creates new form PlotForm */
    public PlotForm(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        
        chooseButton.setVisible(false);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        plotTypeButtonGroup = new javax.swing.ButtonGroup();
        fileTypeButtonGroup = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        plotRadioButton = new javax.swing.JRadioButton();
        histRadioButton = new javax.swing.JRadioButton();
        plot3dRadioButton = new javax.swing.JRadioButton();
        phaseplotRadioButton = new javax.swing.JRadioButton();
        jPanel2 = new javax.swing.JPanel();
        saveToFileCheckBox = new javax.swing.JCheckBox();
        filenameLabel = new javax.swing.JLabel();
        filenameText = new javax.swing.JTextField();
        filetypeLabel = new javax.swing.JLabel();
        pngRadioButton = new javax.swing.JRadioButton();
        jpgRadioButton = new javax.swing.JRadioButton();
        pdfRadioButton = new javax.swing.JRadioButton();
        txtRadioButton = new javax.swing.JRadioButton();
        chooseButton = new javax.swing.JButton();
        backButton = new javax.swing.JButton();
        nextButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        datavarsList = new javax.swing.JList();
        helpButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(sea.SimHyAGui.class).getContext().getResourceMap(PlotForm.class);
        setTitle(resourceMap.getString("PlotForm.title")); // NOI18N
        setName("PlotForm"); // NOI18N
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                formComponentShown(evt);
            }
        });

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.setName("jPanel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        plotTypeButtonGroup.add(plotRadioButton);
        plotRadioButton.setSelected(true);
        plotRadioButton.setText(resourceMap.getString("plotRadioButton.text")); // NOI18N
        plotRadioButton.setName("plotRadioButton"); // NOI18N

        plotTypeButtonGroup.add(histRadioButton);
        histRadioButton.setText(resourceMap.getString("histRadioButton.text")); // NOI18N
        histRadioButton.setName("histRadioButton"); // NOI18N

        plotTypeButtonGroup.add(plot3dRadioButton);
        plot3dRadioButton.setText(resourceMap.getString("plot3dRadioButton.text")); // NOI18N
        plot3dRadioButton.setName("plot3dRadioButton"); // NOI18N

        plotTypeButtonGroup.add(phaseplotRadioButton);
        phaseplotRadioButton.setText(resourceMap.getString("phaseplotRadioButton.text")); // NOI18N
        phaseplotRadioButton.setName("phaseplotRadioButton"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(plotRadioButton)
                    .addComponent(histRadioButton)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(plot3dRadioButton)
                    .addComponent(phaseplotRadioButton))
                .addContainerGap(85, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(plotRadioButton)
                    .addComponent(plot3dRadioButton))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(histRadioButton)
                    .addComponent(phaseplotRadioButton))
                .addContainerGap(11, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel2.setName("jPanel2"); // NOI18N

        saveToFileCheckBox.setText(resourceMap.getString("saveToFileCheckBox.text")); // NOI18N
        saveToFileCheckBox.setName("saveToFileCheckBox"); // NOI18N
        saveToFileCheckBox.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                saveToFileCheckBoxStateChanged(evt);
            }
        });

        filenameLabel.setText(resourceMap.getString("filenameLabel.text")); // NOI18N
        filenameLabel.setEnabled(false);
        filenameLabel.setName("filenameLabel"); // NOI18N

        filenameText.setText(resourceMap.getString("filenameText.text")); // NOI18N
        filenameText.setEnabled(false);
        filenameText.setName("filenameText"); // NOI18N

        filetypeLabel.setText(resourceMap.getString("filetypeLabel.text")); // NOI18N
        filetypeLabel.setEnabled(false);
        filetypeLabel.setName("filetypeLabel"); // NOI18N

        fileTypeButtonGroup.add(pngRadioButton);
        pngRadioButton.setText(resourceMap.getString("pngRadioButton.text")); // NOI18N
        pngRadioButton.setEnabled(false);
        pngRadioButton.setName("pngRadioButton"); // NOI18N

        fileTypeButtonGroup.add(jpgRadioButton);
        jpgRadioButton.setText(resourceMap.getString("jpgRadioButton.text")); // NOI18N
        jpgRadioButton.setEnabled(false);
        jpgRadioButton.setName("jpgRadioButton"); // NOI18N

        fileTypeButtonGroup.add(pdfRadioButton);
        pdfRadioButton.setText(resourceMap.getString("pdfRadioButton.text")); // NOI18N
        pdfRadioButton.setEnabled(false);
        pdfRadioButton.setName("pdfRadioButton"); // NOI18N

        fileTypeButtonGroup.add(txtRadioButton);
        txtRadioButton.setText(resourceMap.getString("txtRadioButton.text")); // NOI18N
        txtRadioButton.setEnabled(false);
        txtRadioButton.setName("txtRadioButton"); // NOI18N

        chooseButton.setText(resourceMap.getString("chooseButton.text")); // NOI18N
        chooseButton.setEnabled(false);
        chooseButton.setName("chooseButton"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(saveToFileCheckBox)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(pngRadioButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jpgRadioButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pdfRadioButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtRadioButton))
                    .addComponent(filetypeLabel)
                    .addComponent(filenameText, javax.swing.GroupLayout.DEFAULT_SIZE, 305, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(filenameLabel)
                        .addGap(32, 32, 32)
                        .addComponent(chooseButton)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(saveToFileCheckBox)
                .addGap(16, 16, 16)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(filenameLabel)
                    .addComponent(chooseButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(filenameText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addComponent(filetypeLabel)
                .addGap(14, 14, 14)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pngRadioButton)
                    .addComponent(jpgRadioButton)
                    .addComponent(pdfRadioButton)
                    .addComponent(txtRadioButton))
                .addContainerGap(7, Short.MAX_VALUE))
        );

        backButton.setText(resourceMap.getString("backButton.text")); // NOI18N
        backButton.setName("backButton"); // NOI18N
        backButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backButtonActionPerformed(evt);
            }
        });

        nextButton.setText(resourceMap.getString("nextButton.text")); // NOI18N
        nextButton.setName("nextButton"); // NOI18N
        nextButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nextButtonActionPerformed(evt);
            }
        });

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        datavarsList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        datavarsList.setName("datavarsList"); // NOI18N
        datavarsList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                datavarsListValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(datavarsList);

        helpButton.setText(resourceMap.getString("helpButton.text")); // NOI18N
        helpButton.setName("helpButton"); // NOI18N
        helpButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                helpButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addComponent(jLabel1)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(backButton)
                        .addGap(30, 30, 30)
                        .addComponent(nextButton)
                        .addGap(3, 3, 3)
                        .addComponent(helpButton)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE))
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nextButton)
                    .addComponent(backButton)
                    .addComponent(helpButton))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
        if (!isInitData) return;
        
        //init datavars list
        datavarsList.removeAll();
        
        //get all datavars
        ArrayList<String> datavars = PublicParam.SimHyACommand.getListOfDataVariables();        
        DefaultListModel lm = new DefaultListModel();
        for (int i = 0; i < datavars.size(); i++) {
            lm.add(i, datavars.get(i));                
        }
        datavarsList.setModel(lm);
        
        //set default selectedIndex = last simulation
        if (lm.getSize() > 0) {
            datavarsList.setSelectedIndex(lm.getSize() - 1);
        }
    }//GEN-LAST:event_formComponentShown

    private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed
        isInitData = true;    
        this.setVisible(false);
    }//GEN-LAST:event_backButtonActionPerformed

    private void nextButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextButtonActionPerformed
        //get data variable
        if (datavarsList.getSelectedIndex() == -1) {
            JOptionPane.showMessageDialog(this, "Please select a data variable from datavars list.");     
            return;
        }
        isInitData = false;
        String datavar = datavarsList.getSelectedValue().toString();
        
        //generate command expression
        toPlotCommand();
        
        //show next form
        PublicParam.PreviousForm = this;
        if (plotRadioButton.isSelected()) {
            //get data variabletype
            //System.out.println(PublicParam.SimHyACommand.isTrajectoryDataVariable(datavar));
            //System.out.println(PublicParam.SimHyACommand.isDeterministicExploratorVariable(datavar));
            //System.out.println(PublicParam.SimHyACommand.isStatisticsExploratorVariable(datavar));
            
            if (PublicParam.SimHyACommand.isTrajectoryDataVariable(datavar)) {
                WinHelper.showDialog(PublicParam.PlotSimulationTypeForm, PlotSimulationTypeForm.class);
            } else if (PublicParam.SimHyACommand.isDeterministicExploratorVariable(datavar)) {
                WinHelper.showDialog(PublicParam.PlotDetermForm, PlotDetermForm.class);
            } else if (PublicParam.SimHyACommand.isStatisticsExploratorVariable(datavar)) {
                WinHelper.showDialog(PublicParam.PlotStatexpForm, PlotStatexplForm.class);
            } else {
                //for test
                //WinHelper.showDialog(PublicParam.PlotDetermForm, PlotDetermForm.class);
            }           
            
        } else if (plot3dRadioButton.isSelected()) {
            WinHelper.showDialog(PublicParam.Plot3DForm, Plot3DForm.class);
        } else if (histRadioButton.isSelected()) {
            WinHelper.showDialog(PublicParam.PlotHistForm, PlotHistForm.class);
        } else if (phaseplotRadioButton.isSelected()) {
            WinHelper.showDialog(PublicParam.PlotPhaseForm, PlotPhaseForm.class);
        }      
    }//GEN-LAST:event_nextButtonActionPerformed

    private void saveToFileCheckBoxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_saveToFileCheckBoxStateChanged
        //file name
        filenameLabel.setEnabled(saveToFileCheckBox.isSelected());
        filenameText.setEnabled(saveToFileCheckBox.isSelected());
        chooseButton.setEnabled(saveToFileCheckBox.isSelected());
        //file type
        filetypeLabel.setEnabled(saveToFileCheckBox.isSelected());
        pngRadioButton.setEnabled(saveToFileCheckBox.isSelected());
        jpgRadioButton.setEnabled(saveToFileCheckBox.isSelected());
        pdfRadioButton.setEnabled(saveToFileCheckBox.isSelected());
        txtRadioButton.setEnabled(saveToFileCheckBox.isSelected());        
    }//GEN-LAST:event_saveToFileCheckBoxStateChanged

    private void datavarsListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_datavarsListValueChanged
        //it should NOT be active for trajectory variables, but only for explore variables. ise 
        //Commander interface methods to check if a data variable is an exploration var.
        String datavar = datavarsList.getSelectedValue().toString();
        if (PublicParam.SimHyACommand.isDeterministicExploratorVariable(datavar)
                || PublicParam.SimHyACommand.isStatisticsExploratorVariable(datavar)) {
            plot3dRadioButton.setEnabled(true);
        } else {
            plot3dRadioButton.setEnabled(false);
            if (plot3dRadioButton.isSelected()) plotRadioButton.setSelected(true);
        }
        //hist
        if (PublicParam.SimHyACommand.isStatisticsExploratorVariable(datavar) 
                || PublicParam.SimHyACommand.isDeterministicExploratorVariable(datavar)) {
            histRadioButton.setEnabled(false);
        } else {
            histRadioButton.setEnabled(true);
        }
        
//        System.out.println(PublicParam.SimHyACommand.isDeterministicExploratorVariable(datavar));
//        System.out.println(PublicParam.SimHyACommand.isStatisticsExploratorVariable(datavar));
//        System.out.println(PublicParam.SimHyACommand.isTrajectoryDataVariable(datavar));
//        
//        System.out.println(PublicParam.SimHyACommand.trajectoryVariableContainsFinalStateData(datavar));
//        System.out.println(PublicParam.SimHyACommand.trajectoryVariableContainsFinalStateHigherOrderMoments(datavar));
//        System.out.println(PublicParam.SimHyACommand.trajectoryVariableContainsStatistics(datavar));
//        System.out.println(PublicParam.SimHyACommand.trajectoryVariableContainsTrajectoryData(datavar));
//        System.out.println(PublicParam.SimHyACommand.trajectoryVariableContainsTrajectoryHigherOrderMoments(datavar));
//        
//        System.out.println(PublicParam.SimHyACommand.exploratorVariableContainsFinalStateData(datavar));
//        System.out.println(PublicParam.SimHyACommand.exploratorVariableContainsFinalStateStatistics(datavar));
//        System.out.println(PublicParam.SimHyACommand.exploratorVariableContainsTrajectoryData(datavar));
//        System.out.println(PublicParam.SimHyACommand.exploratorVariableContainsTrajectoryStatistics(datavar));
        
        //phaseplot
        //phaseplot for explore data should not be enabled if there is not data about trajectories 
        //but only about final state.
        if (PublicParam.SimHyACommand.trajectoryVariableContainsFinalStateData(datavar)
                && !PublicParam.SimHyACommand.trajectoryVariableContainsStatistics(datavar)
                && !PublicParam.SimHyACommand.trajectoryVariableContainsTrajectoryData(datavar)
                || (PublicParam.SimHyACommand.exploratorVariableContainsFinalStateData(datavar)
                && !PublicParam.SimHyACommand.exploratorVariableContainsTrajectoryData(datavar)
                && !PublicParam.SimHyACommand.exploratorVariableContainsTrajectoryStatistics(datavar))) {
            phaseplotRadioButton.setEnabled(false);
        } else {
            phaseplotRadioButton.setEnabled(true);
        }
        
    }//GEN-LAST:event_datavarsListValueChanged

    private void helpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpButtonActionPerformed
        WinHelper.showHelp("plot/plot");
    }//GEN-LAST:event_helpButtonActionPerformed
    
    void toPlotCommand() {
        String s = "";
        
        //command
        if (plotRadioButton.isSelected()) {
            s = "plot(";
        } else if (plot3dRadioButton.isSelected()) {
            s = "plot3d(";
        } else if (histRadioButton.isSelected()) {
            s = "hist(";
        } else if (phaseplotRadioButton.isSelected()) {
            s = "phaseplot(";
        }
        
        //data variable
        s += "$" + datavarsList.getSelectedValue().toString();
        
        //save file
        if (saveToFileCheckBox.isSelected() && filenameText.getText().length() > 0) {
            s += ",file=" + filenameText.getText();
        }
        
        //file type
        if (saveToFileCheckBox.isSelected()) {
            if (pngRadioButton.isSelected()) {
                s += ",filetype=png";
            } else if (jpgRadioButton.isSelected()) {
                s += ",filetype=jpg";
            } else if (pdfRadioButton.isSelected()) {
                s += ",filetype=pdf";
            } else if (txtRadioButton.isSelected()) {
                s += ",filetype=tex";
            }
        }
        
        PublicParam.SimHyACommandExpression = s;
        
    }
    
    public String getCurrentDataVariable() {
        return datavarsList.getSelectedValue().toString();
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                PlotForm dialog = new PlotForm(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton backButton;
    private javax.swing.JButton chooseButton;
    private javax.swing.JList datavarsList;
    private javax.swing.ButtonGroup fileTypeButtonGroup;
    private javax.swing.JLabel filenameLabel;
    private javax.swing.JTextField filenameText;
    private javax.swing.JLabel filetypeLabel;
    private javax.swing.JButton helpButton;
    private javax.swing.JRadioButton histRadioButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JRadioButton jpgRadioButton;
    private javax.swing.JButton nextButton;
    private javax.swing.JRadioButton pdfRadioButton;
    private javax.swing.JRadioButton phaseplotRadioButton;
    private javax.swing.JRadioButton plot3dRadioButton;
    private javax.swing.JRadioButton plotRadioButton;
    private javax.swing.ButtonGroup plotTypeButtonGroup;
    private javax.swing.JRadioButton pngRadioButton;
    private javax.swing.JCheckBox saveToFileCheckBox;
    private javax.swing.JRadioButton txtRadioButton;
    // End of variables declaration//GEN-END:variables
    
    boolean isInitData = true;//init listbox before show
}
